/**
 * Created by huangzx on 2015/12/7.
 */
define( ['angular',
    'framework/msg/GillionMsgModule',
    'framework/tab/GillionTabModule',
    'jquery-sortable',
    'bootstrap'], function (angular) {
    var module= angular.module('HomeModule', ['GillionTabModule']).controller('HomeController', ['$scope', function ($scope) {
        angular.element(".tree a.nav").on('click', function(){
            angular.element(this).next('.node').toggle();
        });

        angular.element('.tree .node a').on('click', function(){
            var $this = angular.element(this);
            $scope.tabPanel.addTab({
                title: $this.data('title'),
                url: $this.data('url'),
                active: true
            });
            angular.element('.tab-body-iframe:last').height(document.body.scrollHeight);
        });

        $scope.initTabPanel = function(tabPanel){
            window.top.openTab = function(title, url) {
                tabPanel.addTab({
                    title: title,
                    url: url,
                    active: true
                });
                angular.element('.tab-body-iframe:last').height(document.body.scrollHeight);
            };
        };
    }]);

    module.config(['$locationProvider', function($locationProvider) {
        $locationProvider.html5Mode(true);
    }]);

    return module;
});